package com.xxc.exam.controller

import com.xxc.common.util.RequestContextHolderUtil
import com.xxc.exam.entity.pojo.Manager
import com.xxc.exam.service.ManagerService
import com.xxc.response.anotation.ResponseResult
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Controller
import org.springframework.ui.ModelMap
import org.springframework.web.bind.annotation.*
import java.math.BigInteger

/**
 * 管理员controller
 */
@RestController
@ResponseResult
class ManagerController {

    @Autowired
    lateinit var managerService: ManagerService

    @PostMapping("/login")
    fun login(@RequestParam email:String,@RequestParam password:String):Manager{
        val auth = managerService.find(email, password)
        RequestContextHolderUtil.getSession().setAttribute("auth",auth)
        return auth
    }

    @PostMapping("/manager")
    fun add(@RequestParam email:String,@RequestParam password:String):BigInteger{
        return managerService.add(email,password)
    }

}